#ifndef _CTIMER_H_
#define _CTIMER_H_

//#include "queue.h"
//#include <sys/time.h>

class CTimer
{
friend class CTimerManager;
public:
	typedef enum
	{
		TIMER_IDLE=0,
		TIMER_ALIVE,
		TIMER_TIMEOUT
	}TimerState;
	typedef enum
	{
		TIMER_ONCE=0,
		TIMER_CIRCLE
	}TimerType;
	CTimer(unsigned int vinterval=0,void (*vfunc)(CTimer *,void *)=0,void *vdata=0,TimerType vtype=TIMER_ONCE);
	void start();
	void stop();
	void reset(unsigned int vinterval);
	~CTimer();
private:
	unsigned int id_;
	unsigned long m_interval;
	unsigned int m_counter;
	struct timeval m_endtime;
	TimerState m_state;
	TimerType m_type;
	void (*m_func)(CTimer *,void *);
	void * m_data;
public:
		LOG4CPLUS_CLASS_DECLARE( _s_logger );

	//TAILQ_ENTRY(CTimer) entry_;
};
#endif
